package com.infolab.scheduler.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.infolab.aims.GlobalConstant;


@Entity
@Table(name="AMTB_INTF_TAXIDOWNTIME")
public class IntfTaxiDowntime implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer intfTaxiDowntimeId;
	
	@NotBlank(message="{error.empty}")
	private String vehicleId;
	
	@NotNull(message="{error.empty}")
	private Date startTime;
	
	@NotNull(message="{error.empty}")
	private Date endTime;
	
	private Date dateCreated;
	private Date dateExecuted;
	
	private String status;

	public Integer getIntfTaxiDowntimeId() {
		return intfTaxiDowntimeId;
	}

	public void setIntfTaxiDowntimeId(Integer intfTaxiDowntimeId) {
		this.intfTaxiDowntimeId = intfTaxiDowntimeId;
	}

	public String getVehicleId() {
		return vehicleId;
	}

	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateExecuted() {
		return dateExecuted;
	}

	public void setDateExecuted(Date dateExecuted) {
		this.dateExecuted = dateExecuted;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	
	public String getStartTimeForXml()
	{
		DateTimeFormatter fmt = DateTimeFormat.forPattern(GlobalConstant.DATE_TIME_FORMAT_INTERFACE);
		
		if(startTime!=null) return new DateTime(startTime.getTime()).toString(fmt);
				
		return "";
	}
	
	public String getEndTimeForXml()
	{
		DateTimeFormatter fmt = DateTimeFormat.forPattern(GlobalConstant.DATE_TIME_FORMAT_INTERFACE);
		
		if(endTime!=null) return new DateTime(endTime.getTime()).toString(fmt);
				
		return "";
	}
	
	
	
}
